#include "PrimitiveMesh.h"
#include "GeomMesh.h"


PrimitiveMesh::PrimitiveMesh( double Mass, const std::string& meshPath ): PrimitiveEllipsoid( Mass )
{
	if (mGeom)
		delete mGeom;
	mGeom = new GeomMesh(mDim/2, mMeshPath);
	mGeom->translate(mOffset);
	mGeom->setPhysObject(this);
	mGeomPtr = static_cast<GeomMesh*>(mGeom);
	size_t pathLen = meshPath.size();
	if (pathLen > 5)
		mMeshPath = meshPath.substr(5, pathLen);
	mMeshPath.append(".obj");
}


PrimitiveMesh::PrimitiveMesh(Vec3d _offset, Vec3d _dim, double Mass, const std::string& meshPath) : PrimitiveEllipsoid(_offset, _dim, Mass), mMeshPath(meshPath)
{
	if (mGeom)
		delete mGeom;
	mGeom = new GeomMesh(mDim/2, mMeshPath);
	mGeom->translate(mOffset);
	mGeom->setPhysObject(this);
	mGeomPtr = static_cast<GeomMesh*>(mGeom);
} 

PrimitiveMesh::~PrimitiveMesh()
{

}